<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>通知管理</title>
	<meta name="decorator" content="default"/>
	 <link href="${ctxStatic }/summernote/summernote.css" type="text/css" rel="stylesheet"/>
    <script src="${ctxStatic }/summernote/summernote.js" type="text/javascript"></script>
    <script src="${ctxStatic }/summernote/toolbar.js" type="text/javascript"></script>
    <script src="${ctxStatic }/summernote/lang/summernote-zh-CN.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			 $("#content").summernote({
                 height: 200,
                 width:600,
                 tabsize: 2,
                 toolbar: toolsBar.smaple,
                 lang: "zh-CN"
             });
			$("#status").change(function(){
				$("#scope").toggle();
			});
			$("#inputForm").validate({
				submitHandler: function(form){
					if(!$("#content").val()) {
						$("#forContent").show();
						return;
					}
					if($("#content").val().length < 10 ) {
						$("#forContent").html("内容太短，请增加内容");
						$("#forContent").show();
						return;
					}
					if($("#content").val().length > 10000) {
						$("#forContent").html("内容超长，请精简输入");
						$("#forContent").show();
						return;
					}
					if($("#status").val() == 0) {
						if($("#officesId").val()) {
							loading("保存并发布中……请稍候");
						} else {
							$("#forScope").html("请选择发布范围");
							$("#forScope").show();
							return;
						}
					} else {
						loading("保存中……请稍候");
					}
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/office/notify/officeNotify/">通知列表</a></li>
		<li class="active">
			<a href="${ctx}/office/notify/officeNotify/form?id=${officeNotify.id}">通知<shiro:hasPermission name="office:officeNotify:edit">${not empty officeNotify.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="office:officeNotify:edit">查看</shiro:lacksPermission></a>
		</li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="officeNotify" action="${ctx}/office/notify/officeNotify/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">类型：</label>
			<div class="controls">
				<form:select path="type" cssClass="select-medium">
					<c:forEach items="${fns:getDictList('OFFICE_NOTIFY_TYPE')}" var="ont">
						<form:option value="${ont.value }">${ont}</form:option>
					</c:forEach>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">标题：</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="100" class="required" placeholder="请输入标题，100字以内"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">内容：</label>
			<div class="controls">
				<form:textarea path="content" htmlEscape="false" rows="4"/>
				<label id="forContent" class="error hide">必填信息</label>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">附件：</label>
			<div class="controls">
				<form:input path="files" htmlEscape="false" maxlength="2000" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">预约提醒时间：</label>
			<div class="controls">
				<input name="remindTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${officeNotify.remindTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">状态：</label>
			<div class="controls">
				<form:select path="status" cssClass="select-medium">
					<c:forEach items="${fns:getDictList('OFFICE_NOTIFY_STATUS')}" var="ons">
						<form:option value="${ons.value }">${ons}</form:option>
					</c:forEach>
				</form:select>
			</div>
		</div>
		<div class="control-group" id="scope">
			<label class="control-label">发布范围：</label>
			<div class="controls">
				<sys:treeselect id="offices" name="officeIds" value="${user.office.id}" labelName="office.name"
					labelValue="${user.office.name}" title="部门" url="/sys/office/treeData?type=2"
					checked="true" allowClear="true" notAllowSelectParent="false" smallBtn="true"
					checkParentOrChild="s"/>
				<label id="forScope" class="error hide">必填信息</label>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="100" class="input-xxlarge" placeholder="100字以内"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="office:officeNotify:edit">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>